package com.rainbow.micro;

import com.rainbow.common.frame.config.UndertowConfig;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

/**
 * 字典服务启动类
 * @author 付为地
 */
@MapperScan("com.rainbow.**.dao")
@EnableFeignClients(basePackages = {"com.rainbow"})
@SpringBootApplication(scanBasePackages = "com.rainbow")
@Import({UndertowConfig.class})
@Slf4j
public class StartApplication {

    public static void main(String[] args) {
        //关闭nexpion控制台打印
        ConfigurableApplicationContext application = SpringApplication.run(StartApplication.class, args);
        Environment env = application.getEnvironment();
        String activeProfiles = StringUtils.arrayToCommaDelimitedString(env.getActiveProfiles());
        activeProfiles = StringUtils.isEmpty(activeProfiles) ? "default" : activeProfiles;
        log.info("\n----------------------------------------------------------\n\t" +
                        "当前项目[{}]启动完成! 运行环境[{}]\n\t" +
                        "访问地址:http://localhost:{}/doc.html\n\t" +
                        "-----------------------------------------------------",
                env.getProperty("spring.application.name"),
                activeProfiles,
                env.getProperty("server.port"));
    }


}
